﻿using UnityEngine;
using System.Collections;

public class ToolTipManager : MonoBehaviour
{

    // Use this for initialization
    private GameObject Waves;
    private int initialTooltips;
    void Start()
    {
        if (moveGUItex.isToolTips)
        {
            Camera.main.GetComponent<PowerUpSpawner>().enabled = false;
            Waves = GameObject.Find("WaveHolder").transform.GetChild(0).gameObject;
            Debug.Log(Waves + " waves");
            Waves.SetActive(false);
            initialTooltips = transform.childCount;
            foreach (Transform child in transform)
            {
                child.gameObject.SetActive(false);
            }
            transform.GetChild(0).gameObject.SetActive(true);
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (moveGUItex.isToolTips)
        {
            int fingerCount = 0;
            if (Input.GetKey(KeyCode.X))
            {
                foreach (Transform child in transform)
                {
                    Destroy(child.gameObject);
                }
            }
            if (Input.touchCount > 0)
            {
                foreach (Touch touch in Input.touches)
                {
                    if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled)
                        fingerCount++;
                }
                if (fingerCount == 2)
                {
                    foreach (Transform child in transform)
                    {
                        Destroy(child.gameObject);
                    }
                }
            }
            if (transform.childCount == 0)
            {

                print("here");
                Debug.Log(Waves + " waves");
                Waves.SetActive(true);
                Camera.main.GetComponent<PowerUpSpawner>().enabled = true;
                Destroy(this);
            }
            else if (transform.childCount != initialTooltips)
            {
                initialTooltips = transform.childCount;
                transform.GetChild(0).gameObject.SetActive(true);
            }
        }
    }
}
